package com.bleeth.flow.core.util;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.http.HttpUtil;

import java.util.List;

/**
 * @author ：Bleeth
 * @date ：2021-10-18
 * @description：给系统设置代理
 */
public class ProxyUtil {


    /**
     * @param proxyType   代理类型
     * @param host        代理host
     * @param port        端口
     * @param noProxyList 不走代理的host
     */
    public static void setSystemProxy(ProxyType proxyType, String host, String port, List<String> noProxyList) {
        if (proxyType.equals(ProxyType.SOCKS)) {
            System.setProperty("socksProxyHost", host);
            System.setProperty("socksProxyPort", port);
        }
    }

    /**
     * @param proxyType   代理类型
     * @param host        代理host
     * @param port        端口
     */
    public static void setSystemProxy(ProxyType proxyType, String host, String port) {
        setSystemProxy(proxyType,host,port, CollUtil.newArrayList());
    }

    //测试代理
    public static void main(String[] args) {
        setSystemProxy(ProxyType.SOCKS, "127.0.0.1", "9922", null);

        //连接coffee
        String s = HttpUtil.get("http://192.168.23.3:9012/Kafka/KaclusterList");
        System.err.println(s);

    }


}
